package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.HashMap;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(73)
public class ZhenlongtzGameStrategy extends BaseGameStrategy {

    public static final String URL = "http://43.139.47.245:15000/api/insert_mail";

    @GongnengMethod(1)
    public String pay(SendItem item) {
        System.out.println("发送充值：金额：");
        return "充值已发送，金额：";
    }

    /**
     * {
     *     "uid": "50001001",
     *     "num": "6",
     *     "itemId": "600062"
     * }
     *
     * @param item
     * @return
     */
    @GongnengMethod(7301)
    public String mail(SendItem item) {
        HashMap<String,String> params = new HashMap<>();
        params.put("uid", item.uid);
        params.put("num", item.number);
        params.put("itemId", item.itemId);

        return RestTemplateUtil.sendPostJsonAndGetJsonKey(URL, params,"message");
    }



    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.uid = "50001001";
        item.number = "121";
        item.itemId = "600062";
        System.out.println(new ZhenlongtzGameStrategy().mail(item));
    }
}

